package com.caigou.comm.base.widget

import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.view.Gravity
import android.view.Window
import android.view.WindowManager
import android.widget.Button
import com.caigou.comm.R
import com.caigou.comm.base.ext.getScreenWidth

/**
 * @author #Suyghur.
 * Created on 2021/12/03
 */
class VipDialog constructor(context: Context) : Dialog(context) {

    lateinit var btnMonth: Button
    lateinit var btnYear: Button
    private lateinit var btnCancel: Button

    init {
        setCanceledOnTouchOutside(true)
        window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        initView(context)
    }

    private fun initView(context: Context) {
        setContentView(R.layout.comm_vip_dialog)

        val attr = window?.attributes as WindowManager.LayoutParams
        //设置dialog在布局中的位置
        attr.gravity = Gravity.CENTER
        attr.width = getScreenWidth(context) - 20

        btnMonth = findViewById(R.id.vip_dialog_btn_month)
        btnYear = findViewById(R.id.vip_dialog_btn_year)
        btnCancel = findViewById(R.id.vip_dialog_btn_cancel)
        btnCancel.setOnClickListener {
            dismiss()
        }
    }

}